package com.wpzf.zxhc.controller;

import com.wpzf.common.core.utils.ServletUtils;
import com.wpzf.common.core.web.domain.AjaxResult;
import com.wpzf.common.log.annotation.Log;
import com.wpzf.common.log.enums.BusinessType;
import com.wpzf.common.security.service.TokenService;
import com.wpzf.common.security.utils.SecurityUtils;
import com.wpzf.system.api.model.LoginUser;
import com.wpzf.zxhc.utils.ExcelUtils;
import com.wpzf.zxhc.utils.GdalUtils;
import com.wpzf.zxhc.utils.MultipleFileUnZip;
import com.wpzf.zxhc.domain.*;
import com.wpzf.zxhc.service.*;
import net.lingala.zip4j.exception.ZipException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@RestController
@RequestMapping("/dkshcity")
public class DkShCityController {
    @Autowired
    DkShCityService dkShCityService;
    @Autowired
    XjtbTbBaseService xjtbTbBaseService;
    @Autowired
    ProvAuditingService provAuditingService;
    @Autowired
    WpzfTbBaseService wpzfTbBaseService;
    @Autowired
    TokenService tokenService;
    @Autowired
    AppService appService;

    @Value("${tempath}")
    public String tempath;

    @RequestMapping(value = "/getCityDkShPch", method = RequestMethod.POST)
    public AjaxResult getCityDkShPch(@RequestBody Map<String, Object> param) {
        try {
            String sXzqdm = param.get("xzqdm") + "";
            if (sXzqdm.trim().isEmpty() || sXzqdm.equals("null")) {
                LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
                param.replace("xzqdm", loginUser.getSysUser().getXzqdm());
            }
            List<Map> list = dkShCityService.getCityDkShPch(param);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getCityDkShInfo", method = RequestMethod.POST)
    public AjaxResult getCityDkShInfo(@RequestBody Map<String, Object> param) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            param.put("xzqdm", loginUser.getSysUser().getXzqdm());
            List<Map> list = dkShCityService.getCityDkShInfo(param);
            int total = list.size();
            int nPageNum = Integer.parseInt(param.get("pageNum") + "");
            int nPageSize = Integer.parseInt(param.get("pageSize") + "");
            List<Map> lstMap = dataPagination(list, nPageNum, nPageSize);
            return AjaxResult.success("获取成功", lstMap, total);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getDkShInfoByXzq", method = RequestMethod.POST)
    public AjaxResult getDkShInfoByXzq(@RequestBody Map<String, Object> param) {
        try {
            List<Map> list = dkShCityService.getDkShInfoByXzq(param);
            int total = list.size();
            int nPageNum = Integer.parseInt(param.get("pageNum") + "");
            int nPageSize = Integer.parseInt(param.get("pageSize") + "");
            List<Map> lstMap = dataPagination(list, nPageNum, nPageSize);
            return AjaxResult.success("获取成功", lstMap, total);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getDkShInfoByXzqIds", method = RequestMethod.POST)
    public AjaxResult getDkShInfoByXzqIds(@RequestBody Map<String, Object> param) {
        try {
            List<Map> list = dkShCityService.getDkShInfoByXzqIds(param);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getLeftData", method = RequestMethod.POST)
    public AjaxResult getLeftData(@RequestBody Map<String, Object> param) {
        try {
            List<Map> list = dkShCityService.getLeftData(param);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    //
    @RequestMapping(value = "/getDkHcInfo", method = RequestMethod.POST)
    public AjaxResult getDkHcInfo(@RequestBody Map<String, Object> parm) {
        String jcbh = parm.get("tbbh") + "";
        if (jcbh.indexOf(",") != -1) {
            String dkbh1 = jcbh.split(",")[0];
            parm.put("jcbh", dkbh1.split("-")[0]);
            parm.replace("tbbh", dkbh1.split("-")[0]);
            parm.put("dkbh", jcbh);
        } else {
            parm.put("jcbh", jcbh.split("-")[0]);
            parm.replace("tbbh", jcbh.split("-")[0]);
            parm.put("dkbh", jcbh);
        }
        try {
            //modelMap
            ModelMap modelMap = xjtbTbBaseService.getShowImgs(parm);//jcbh-xzqdm-pch
            //地块信息
            WpCjDkxxbxj2023DTO dkxxbxj2023DTO = dkShCityService.getDkInfoByDkbh(parm);//dkbh-pch
            //关联地块信息
            List<WpCjDkxxbxj2023DTO> dkxxbxj2023DTOList = dkShCityService.getRelationDkInfoByJcbh(parm);//jcbh-pch
            //核查结果
            Map wpCjTbhcjgSj2023 = dkShCityService.getCityDkHcJgInfo(parm);//tbbh-pch
            if (wpCjTbhcjgSj2023 == null) {
                wpCjTbhcjgSj2023 = new HashMap();
                wpCjTbhcjgSj2023.put("hcjl", "");
                wpCjTbhcjgSj2023.put("hcsm", "");
            }
            //图斑示意图
            List<WpCjTbjt2023DTO> wpCjTbjt2023DTOS = wpzfTbBaseService.querytbjtBytbbh(parm);//tbbh-xzqdm-pch
            //图斑信息
            List<WpCjTbxxbxj2023DTO> tbxxbxj2023DTOS = dkShCityService.getTbInfoByJcbh(parm);//jcbh-pch

            List<WpCjDkxxbxj2023DTO> dkxxbxjWtg2023DTOS = xjtbTbBaseService.queryWpCjDkInfoByJcbh(parm);

            Map<String, Object> map = new HashMap<>();
            map.put("modelMap", modelMap);
            map.put("wpCjDkxxb2023dto", dkxxbxj2023DTO);
            map.put("wpCjDkxxb2023relatedto", dkxxbxj2023DTOList);
            map.put("wpCjTbhcjg2023DTOS", wpCjTbhcjgSj2023);
            map.put("wpCjTbjt2023DTOS", wpCjTbjt2023DTOS);
            map.put("wpCjTbxxb2023DTOS", tbxxbxj2023DTOS);
            map.put("wpCjDkxxbxj2023List", dkxxbxjWtg2023DTOS);
            return AjaxResult.success("获取成功", map);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    /**/
    @RequestMapping(value = "/addHcjgSj", method = RequestMethod.POST)
    public AjaxResult addHcjgSj(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            parm.put("hcr", loginUser.getUsername());
            Integer nSelCount = dkShCityService.selectDkHcJg(parm);
            if (nSelCount > 0) {
                Integer nUp = dkShCityService.updateDkHcJg(parm);
            } else {
                Integer nInsertJg = dkShCityService.insertDkHcJg(parm);
            }
            /*Integer nDel = dkShCityService.deleteDkHcJg(parm);
            Integer nInsertLz = dkShCityService.insertOperationFlow(parm);
            String hcjl = parm.get("hcjl") + "";
            if (hcjl.equals("同意")) {
                parm.put("dkzt", 3);
            } else {
                parm.put("dkzt", 4);
            }
            Integer nUpdate = dkShCityService.updateDkzt(parm);*/
            List<Map> list = dkShCityService.getDkShInfoByXzqIds(parm);
            return AjaxResult.success("添加核查结果成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("添加核查结果失败", ex.toString());
        }
    }

    /**/
    @RequestMapping(value = "/returnDkHcXj", method = RequestMethod.POST)
    public AjaxResult returnDkHcXj(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            parm.put("hcr", loginUser.getUsername());
            List<Map> lstMap = objToList(parm.get("dkbh"), Map.class);
            Integer nUpdate = 0;
            for (Map m : lstMap) {
                m.put("hcr", loginUser.getUsername());
                m.put("thyy", parm.get("thyy"));
                Integer nInsertLz = dkShCityService.insertOperationFlow(m);
                //String hcjl = parm.get("hcjl") + "";
                //if (hcjl.equals("同意")) {
                //    parm.put("dkzt", 3);
                //} else {
                m.replace("dkzt", 4);
                //}
                nUpdate += dkShCityService.updateDkzt(m);
            }
            return AjaxResult.success("退回成功", nUpdate);
        } catch (Exception ex) {
            return AjaxResult.error("退回失败", ex.toString());
        }
    }

    /**/
    @RequestMapping(value = "/citySubmit", method = RequestMethod.POST)
    public AjaxResult citySubmit(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            parm.put("czr", loginUser.getUsername());
            Integer nSubmit = dkShCityService.citySubmit(parm);
            return AjaxResult.success("提交成功", nSubmit);
        } catch (Exception ex) {
            return AjaxResult.error("提交失败", ex.toString());
        }
    }

    /**/
    @RequestMapping(value = "/getProvBackDkInfo", method = RequestMethod.POST)
    public AjaxResult getProvBackDkInfo(@RequestBody Map<String, Object> param) {
        try {
            String sXzqdm = param.get("xzqdm") + "";
            if (sXzqdm.trim().isEmpty() || sXzqdm.equals("null")) {
                LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
                param.replace("xzqdm", loginUser.getSysUser().getXzqdm() + "");
            }
            List<Map> list = dkShCityService.getProvBackDkInfo(param);
            int total = list.size();
            int nPageNum = Integer.parseInt(param.get("pageNum") + "");
            int nPageSize = Integer.parseInt(param.get("pageSize") + "");
            List<Map> lstMap = dataPagination(list, nPageNum, nPageSize);
            return AjaxResult.success("获取成功", lstMap, total);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    /**/
    @RequestMapping(value = "/getProvBackPch", method = RequestMethod.POST)
    public AjaxResult getProvBackPch(@RequestBody Map<String, Object> param) {
        try {
            String sXzqdm = param.get("xzqdm") + "";
            if (sXzqdm.trim().isEmpty() || sXzqdm.equals("null")) {
                LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
                param.put("xzqdm", loginUser.getSysUser().getXzqdm() + "");
            }
            List<Map> list = dkShCityService.getProvBackPch(param);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    /**/
    @RequestMapping(value = "/getDkFlowInfo", method = RequestMethod.POST)
    public AjaxResult getDkFlowInfo(@RequestBody Map<String, Object> param) {
        try {
            List<Map> list = dkShCityService.getDkFlowInfo(param);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getXjZgDkInfo", method = RequestMethod.POST)
    public AjaxResult getXjZgDkInfo(@RequestBody Map<String, Object> param) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            param.replace("xzqdm", loginUser.getSysUser().getXzqdm());
            List<Map> list = dkShCityService.getXjZgDkInfo(param);
            int total = list.size();
            int nPageNum = Integer.parseInt(param.get("pageNum") + "");
            int nPageSize = Integer.parseInt(param.get("pageSize") + "");
            List<Map> lstMap = dataPagination(list, nPageNum, nPageSize);
            return AjaxResult.success("获取成功", lstMap, total);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getXjZgDkInfoIds", method = RequestMethod.POST)
    public AjaxResult getXjZgDkInfoIds(@RequestBody Map<String, Object> param) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            param.replace("xzqdm", loginUser.getSysUser().getXzqdm());
            List<Map> list = dkShCityService.getXjZgDkInfoIds(param);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    /**/
    @RequestMapping(value = "/getXjZgDkPch", method = RequestMethod.POST)
    public AjaxResult getXjZgDkPch(@RequestBody Map<String, Object> param) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            param.put("xzqdm", loginUser.getSysUser().getXzqdm());
            List<Map> list = dkShCityService.getXjZgDkPch(param);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getXjZgDkLeftData", method = RequestMethod.POST)
    public AjaxResult getXjZgDkLeftData(@RequestBody Map<String, Object> param) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            param.replace("xzqdm", loginUser.getSysUser().getXzqdm());
            List<Map> list = dkShCityService.getXjZgDkLeftData(param);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    //
    @RequestMapping(value = "/getDkHcInfoXjZg", method = RequestMethod.POST)
    public AjaxResult getDkHcInfoXjZg(@RequestBody Map<String, Object> parm) {
        String jcbh = parm.get("tbbh") + "";
        if (jcbh.indexOf(",") != -1) {
            String dkbh1 = jcbh.split(",")[0];
            parm.put("jcbh", dkbh1.split("-")[0]);
            parm.replace("tbbh", dkbh1.split("-")[0]);
            parm.put("dkbh", jcbh);
        } else {
            parm.put("jcbh", jcbh.split("-")[0]);
            parm.replace("tbbh", jcbh.split("-")[0]);
            parm.put("dkbh", jcbh);
        }
        try {
            //modelMap
            ModelMap modelMap = xjtbTbBaseService.getShowImgs(parm);//jcbh-xzqdm-pch
            //地块信息
            WpCjDkxxbxj2023DTO dkxxbxj2023DTO = dkShCityService.getDkInfoByDkbh(parm);//dkbh-pch
            //关联地块信息
            List<WpCjDkxxbxj2023DTO> dkxxbxj2023DTOList = dkShCityService.getRelationDkInfoByJcbh(parm);//jcbh-pch
            //核查结果
            Map wpCjTbhcjgSj2023 = dkShCityService.getDkHcJgInfoXjZg(parm);//tbbh-pch
            if (wpCjTbhcjgSj2023 == null) {
                wpCjTbhcjgSj2023 = new HashMap();
                wpCjTbhcjgSj2023.put("hcjl", "");
                wpCjTbhcjgSj2023.put("hcsm", "");
            }
            //图斑示意图
            List<WpCjTbjt2023DTO> wpCjTbjt2023DTOS = wpzfTbBaseService.querytbjtBytbbh(parm);//tbbh-xzqdm-pch
            //图斑信息
            List<WpCjTbxxbxj2023DTO> tbxxbxj2023DTOS = dkShCityService.getTbInfoByJcbh(parm);//jcbh-pch

            Map<String, Object> map = new HashMap<>();
            map.put("modelMap", modelMap);
            map.put("wpCjDkxxb2023dto", dkxxbxj2023DTO);
            map.put("wpCjDkxxb2023relatedto", dkxxbxj2023DTOList);
            map.put("wpCjTbhcjg2023DTOS", wpCjTbhcjgSj2023);
            map.put("wpCjTbjt2023DTOS", wpCjTbjt2023DTOS);
            map.put("wpCjTbxxb2023DTOS", tbxxbxj2023DTOS);
            return AjaxResult.success("获取成功", map);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    /**/
    @RequestMapping(value = "/addHcjgSjXjZg", method = RequestMethod.POST)
    public AjaxResult addHcjgSjXjZg(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            parm.put("hcr", loginUser.getUsername());
            Integer nSelCount = dkShCityService.selectDkHcJg(parm);
            if (nSelCount > 0) {
                Integer nUp = dkShCityService.updateDkHcJgXjZg(parm);
            } else {
                Integer nInsertJg = dkShCityService.insertDkHcJg(parm);
            }
            /*Integer nDel = dkShCityService.deleteDkHcJg(parm);
            Integer nInsertLz = dkShCityService.insertOperationFlow(parm);
            String hcjl = parm.get("hcjl") + "";
            if (hcjl.equals("同意")) {
                parm.put("dkzt", 3);
            } else {
                parm.put("dkzt", 4);
            }
            Integer nUpdate = dkShCityService.updateDkzt(parm);*/
            List<Map> list = dkShCityService.getXjZgDkInfoIds(parm);
            return AjaxResult.success("添加核查结果成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("添加核查结果失败", ex.toString());
        }
    }

    /**/
    @RequestMapping(value = "/xjZgSubmit", method = RequestMethod.POST)
    public AjaxResult xjZgSubmit(@RequestBody Map<String, Object> parm) {
        try {
            Integer nSubmit = -1;
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            List<Map> lstMap = objToList(parm.get("dkxx"), Map.class);
            for (Map m : lstMap) {
                m.put("dkzt", "6");
                m.put("hcr", loginUser.getUsername());
                nSubmit += dkShCityService.xjZgSubmit(m);
            }
            return AjaxResult.success("提交成功", nSubmit);
        } catch (Exception ex) {
            return AjaxResult.error("提交失败", ex.toString());
        }
    }

    public String method(Object object) {
        String obj = object != null ? object.toString() : "";
        return obj;
    }

    public static <T> List<T> objToList(Object obj, Class<T> cla) {
        List<T> list = new ArrayList<T>();
        if (obj instanceof ArrayList<?>) {
            for (Object o : (List<?>) obj) {
                list.add(cla.cast(o));
            }
            return list;
        }
        return null;
    }

    private List<Map> dataPagination(List<Map> lstData, int nPageNum, int nPageSize) {
        List<Map> lstMap = new ArrayList<>();
        int nStartIdx = nPageNum - 1;
        lstMap = lstData.stream().skip(nStartIdx * nPageSize).limit(nPageSize).collect(Collectors.toList());
        return lstMap;
    }

    //暂存
    @RequestMapping(value = "/saveShiTbjg", method = RequestMethod.POST)
    public AjaxResult saveShiTbjg(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            parm.put("hcr", loginUser.getUsername());
            Integer rest = dkShCityService.saveShiTbjg(parm);
            return AjaxResult.success("保存 成功", rest);
        } catch (Exception ex) {
            return AjaxResult.error("保存 失败", ex.toString());
        }
    }

    //市级地块审核详情
    @RequestMapping(value = "/getShiShTaskInfo", method = RequestMethod.POST)
    public AjaxResult getShiShTaskInfo(@RequestBody Map<String, Object> parm) {
        String jcbh = parm.get("jcbh") + "";
        parm.put("tbbh", parm.get("dkbh"));
        if (jcbh.indexOf(",") != -1) {
            parm.put("jcbh", jcbh.split("-")[0]);
        }
        try {
            WpCjTbBaseinfosjDTO wpcjTbBaseinfosjDTO = new WpCjTbBaseinfosjDTO();
            List<WpCjDkpw2023DTO> lists = new ArrayList<>();
            //获取地块信息  dkxxbxj2023DTOS
            WpCjDkxxbxj2023DTO wpcjDkxxb2023DTO = dkShCityService.getDkInfoByDkbh(parm);
            wpcjTbBaseinfosjDTO.setWpCjDkxxb2023dto(wpcjDkxxb2023DTO);

            //获取图斑信息 相关图斑全部查出
            List<WpCjTbxxbxj2023DTO> wpCjTbxxb2023DTOS = dkShCityService.getTbxxbxjByJcbhList(parm);
            wpcjTbBaseinfosjDTO.setWpCjTbxxb2023DTOS(wpCjTbxxb2023DTOS);


            //其他相关的拆分图斑
            List<WpCjDkxxbxj2023DTO> wpCjDkxxb2023relatedto = xjtbTbBaseService.queryWpCjDkInfoByJcbh(parm);
            /*if (wpCjDkxxb2023relatedto.size() > 0) {
                for (int i = 0; i < wpCjDkxxb2023relatedto.size(); i++) {
                    lists = new ArrayList<>();
                    WpCjDkxxbxj2023DTO model = wpCjDkxxb2023relatedto.get(i);

                    if (!("null").equals(model.getNydzypzwh()) && !("").equals(model.getNydzypzwh()) && model.getNydzypzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getNydzypzwh()).split(","); //批准文号
                        String[] pwlyarr = method(model.getNydzypwly()).split(",");
                        String[] pzmjarr = method(model.getNydzypzmj()).split(",");
                        String[] pzrqarr = method(model.getNydzypzrq()).split(",");

                        //江西没有
                        String[] tdgypwlxejlarr = method(model.getNydzytdgypwlxejl()).split(",");
                        String[] pwlbarr = method(model.getNydzypwlb()).split(",");
                        String[] pznydmjarr = method(model.getNydzypznydmj()).split(",");
                        String[] pzgdmjarr = method(model.getNydzypzgdmj()).split(",");
                        String[] pzyjjbntmjarr = method(model.getNydzypzyjjbntmj()).split(",");

                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("农用地转用");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "" && pzrqarr.length > j) {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "" && pwlyarr.length > j) {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "" && pzmjarr.length > j) {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "" && tdgypwlxejlarr.length > j) {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "" && pwlbarr.length > j) {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "" && pznydmjarr.length > j) {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "" && pzgdmjarr.length > j) {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "" && pzyjjbntmjarr.length > j) {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getZjggpzwh()) && !("").equals(model.getZjggpzwh()) && model.getZjggpzwh() != null) //增加挂钩批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getZjggpzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getZjggtdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getZjggpwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getZjggpzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getZjggpwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getZjggpzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getZjggpznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getZjggpzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getZjggpzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("增减挂钩");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "" && pzrqarr.length > j) {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "" && pwlyarr.length > j) {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "" && pzmjarr.length > j) {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "" && tdgypwlxejlarr.length > j) {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "" && pwlbarr.length > j) {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "" && pznydmjarr.length > j) {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "" && pzgdmjarr.length > j) {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "" && pzyjjbntmjarr.length > j) {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getGkfqdpzwh()) && !("").equals(model.getGkfqdpzwh()) && model.getGkfqdpzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getGkfqdpzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getGkfqdtdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getGkfqdpwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getGkfqdpzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getGkfqdpwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getGkfqdpzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getGkfqdpznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getGkfqdpzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getGkfqdpzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("工矿废弃地");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "" && pzrqarr.length > j) {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "" && pwlyarr.length > j) {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "" && pzmjarr.length > j) {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "" && tdgypwlxejlarr.length > j) {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "" && pwlbarr.length > j) {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "" && pznydmjarr.length > j) {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "" && pzgdmjarr.length > j) {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "" && pzyjjbntmjarr.length > j) {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getBdcqzspzwh()) && !("").equals(model.getBdcqzspzwh()) && model.getBdcqzspzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getBdcqzspzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getBdcqzstdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getBdcqzspwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getBdcqzspzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getBdcqzspwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getBdcqzspzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getBdcqzspznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getBdcqzspzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getBdcqzspzzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("不动产权证书");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "" && pzrqarr.length > j) {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "" && pwlyarr.length > j) {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "" && pzmjarr.length > j) {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "" && tdgypwlxejlarr.length > j) {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "" && pwlbarr.length > j) {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "" && pznydmjarr.length > j) {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "" && pzgdmjarr.length > j) {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "" && pzyjjbntmjarr.length > j) {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getSsnydpzwh()) && !("").equals(model.getSsnydpzwh()) && model.getSsnydpzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getSsnydpzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getSsnydtdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getSsnydpwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getSsnydpzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getSsnydpwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getSsnydpzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getSsnydpznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getSsnydpzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getSsnydpzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("设施农用地");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "" && pzrqarr.length > j) {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "" && pwlyarr.length > j) {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "" && pzmjarr.length > j) {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "" && tdgypwlxejlarr.length > j) {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "" && pwlbarr.length > j) {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "" && pznydmjarr.length > j) {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "" && pzgdmjarr.length > j) {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "" && pzyjjbntmjarr.length > j) {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getTdzzyspzwh()) && !("").equals(model.getTdzzyspzwh()) && model.getTdzzyspzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getTdzzyspzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getTdzzystdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getTdzzyspwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getTdzzyspzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getTdzzyspwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getTdzzyspzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getTdzzyspznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getTdzzyspzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getTdzzyspzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("土地整治验收");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "" && pzrqarr.length > j) {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "" && pwlyarr.length > j) {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "" && pzmjarr.length > j) {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "" && tdgypwlxejlarr.length > j) {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "" && pwlbarr.length > j) {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "" && pznydmjarr.length > j) {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "" && pzgdmjarr.length > j) {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "" && pzyjjbntmjarr.length > j) {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getLsydpzwh()) && !("").equals(model.getLsydpzwh()) && model.getLsydpzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getLsydpzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getLsydtdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getLsydpwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getLsydpzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getLsydpwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getLsydpzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getLsydpznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getLsydpzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getLsydpzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("临时用地");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "" && pzrqarr.length > j) {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "" && pwlyarr.length > j) {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "" && pzmjarr.length > j) {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "" && tdgypwlxejlarr.length > j) {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "" && pwlbarr.length > j) {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "" && pznydmjarr.length > j) {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "" && pzgdmjarr.length > j) {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "" && pzyjjbntmjarr.length > j) {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getTdgypzwh()) && !("").equals(model.getTdgypzwh()) && model.getTdgypzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getTdgypzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getTdgytdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getTdgypwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getTdgypzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getTdgypwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getTdgypzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getTdgypznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getTdgypzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getTdgypzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("土地供应");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "" && pzrqarr.length > j) {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "" && pwlyarr.length > j) {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "" && pzmjarr.length > j) {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "" && tdgypwlxejlarr.length > j) {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "" && pwlbarr.length > j) {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "" && pznydmjarr.length > j) {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "" && pzgdmjarr.length > j) {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "" && pzyjjbntmjarr.length > j) {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getXxydpzwh()) && !("").equals(model.getXxydpzwh()) && model.getXxydpzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getXxydpzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getXxydtdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getXxydpwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getXxydpzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getXxydpwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getXxydpzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getXxydpznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getXxydpzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getXxydpzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("先行用地");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "" && pzrqarr.length > j) {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "" && pwlyarr.length > j) {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "" && pzmjarr.length > j) {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "" && tdgypwlxejlarr.length > j) {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "" && pwlbarr.length > j) {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "" && pznydmjarr.length > j) {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "" && pzgdmjarr.length > j) {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "" && pzyjjbntmjarr.length > j) {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getYspzwh()) && !("").equals(model.getYspzwh()) && model.getYspzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getYspzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getYstdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getYspwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getYspzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getYspwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getYspzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getYspznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getYspzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getYspzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("预审");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "" && pzrqarr.length > j) {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "" && pwlyarr.length > j) {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "" && pzmjarr.length > j) {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "" && tdgypwlxejlarr.length > j) {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "" && pwlbarr.length > j) {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "" && pznydmjarr.length > j) {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "" && pzgdmjarr.length > j) {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "" && pzyjjbntmjarr.length > j) {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getQtpzwh()) && !("").equals(model.getQtpzwh()) && model.getQtpzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getQtpzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getQttdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getQtpwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getQtpzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getQtpwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getQtpzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getQtpznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getQtpzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getQtpzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("其他");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "" && pzrqarr.length > j) {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "" && pwlyarr.length > j) {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "" && pzmjarr.length > j) {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "" && tdgypwlxejlarr.length > j) {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "" && pwlbarr.length > j) {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "" && pznydmjarr.length > j) {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "" && pzgdmjarr.length > j) {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "" && pzyjjbntmjarr.length > j) {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    model.setHfpwlist(lists);
                }
            }*/
            wpcjTbBaseinfosjDTO.setWpCjDkxxb2023relatedto(wpCjDkxxb2023relatedto);


            //获取举证照片
            parm.put("sfzz", "自主提取".equals(wpCjTbxxb2023DTOS.get(0).getGjxfhzztq()) ? "1" : "0");
            WpCjGsinfoly2024DTO gsinfoly = xjtbTbBaseService.getGsinfoly(parm);

            wpcjTbBaseinfosjDTO.setWpCjGsinfoly2024DTO(gsinfoly);

            ModelMap modelMap = new ModelMap();
            if ("0".equals(gsinfoly.getInfoly())) {
                modelMap = xjtbTbBaseService.getShowImgsnew(parm);
            } else if ("1".equals(gsinfoly.getInfoly())) {
                List<String> list = new ArrayList<>();
                list.add(appService.getInfo(parm));
//                System.out.println(list);
                modelMap.put("data", list);
            }
            wpcjTbBaseinfosjDTO.setModelMap(modelMap);

            //图斑截图
            List<WpCjTbjt2023DTO> wpCjTbjt2023DTOS = xjtbTbBaseService.querytbjtBytbbhsheng1(parm);
            wpcjTbBaseinfosjDTO.setWpCjTbjt2023DTOS(wpCjTbjt2023DTOS);

            //获取市级审核信息
            WpCjTbhcjgshij2023 tbhcjgshijByDkbh = dkShCityService.getTbhcjgshijByDkbh(parm);
            wpcjTbBaseinfosjDTO.setWpCjTbhcjgshij2023(tbhcjgshijByDkbh);

            return AjaxResult.success("获取成功", wpcjTbBaseinfosjDTO);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    //市级提交到省级
    @RequestMapping(value = "/shiSubmit", method = RequestMethod.POST)
    public AjaxResult shiSubmit(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            parm.put("hcr", loginUser.getUsername());
            parm.put("czr", loginUser.getUsername());
            parm.put("realname", loginUser.getSysUser().getNickName());
            Integer rest = dkShCityService.shiSubmit(parm);
            return AjaxResult.success("市级提交到省级 成功", rest);
        } catch (Exception ex) {
            return AjaxResult.error("市级提交到省级 失败", ex.toString());
        }
    }


    //省级复审提交到省级
    @RequestMapping(value = "/shiSubmitZG", method = RequestMethod.POST)
    public AjaxResult shiSubmitZG(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            parm.put("hcr", loginUser.getUsername());
            parm.put("czr", loginUser.getUsername());
            parm.put("realname", loginUser.getSysUser().getNickName());
            Integer rest = dkShCityService.shiSubmitZG(parm);
            return AjaxResult.success("市级提交到省级 成功", rest);
        } catch (Exception ex) {
            return AjaxResult.error("市级提交到省级 失败", ex.toString());
        }
    }

    //市级退回修改
    @RequestMapping(value = "/shiThxg", method = RequestMethod.POST)
    public AjaxResult shiThxg(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            parm.put("hcr", loginUser.getUsername());
            parm.put("czr", loginUser.getUsername());
            parm.put("realname", loginUser.getSysUser().getNickName());
            Integer rest = dkShCityService.shiThxg(parm);
            return AjaxResult.success("退回修改 成功", rest);
        } catch (Exception ex) {
            return AjaxResult.error("退回修改 失败", ex.toString());
        }
    }

    //
    @RequestMapping(value = "/queryShiTask", method = RequestMethod.POST)
    public AjaxResult queryShiTaskByIndex(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = SecurityUtils.getLoginUser();
            String xzqdmjq = loginUser.getSysUser().getXzqdmjq();
            String[] xzqdmjqArray = null;
            if (xzqdmjq != null && !"".equals(xzqdmjq)) {
                xzqdmjqArray = xzqdmjq.split(",");
            }
            parm.put("xzqdmjqArray", xzqdmjqArray);

            List<Integer> lstDkzt = new ArrayList<>();
            String dkzts = parm.get("dkzt") + "";
            if (!dkzts.isEmpty()) {
                for (String zt : dkzts.split(",")) {
                    lstDkzt.add(Integer.parseInt(zt.replace("'", "")));
                }
                parm.put("lstDkzt", lstDkzt);
            }
            List<YtbTbInfo> rest = dkShCityService.queryShiTaskEX(parm);
            int total = rest.size();
            int nPageNum = Integer.parseInt(parm.get("pageNum") + "");
            int nPageSize = Integer.parseInt(parm.get("pageSize") + "");
            List<YtbTbInfo> lstMap = dataPaginationYtbTbInfo(rest, nPageNum, nPageSize);
            return AjaxResult.success("获取成功", lstMap, total);

            //List<YtbTbInfo> rest = dkShCityService.queryShiTask(parm);
            //return AjaxResult.success(" 成功", rest);
        } catch (Exception ex) {
            return AjaxResult.error(" 失败", ex.toString());
        }
    }

    private List<YtbTbInfo> dataPaginationYtbTbInfo(List<YtbTbInfo> lstData, int nPageNum, int nPageSize) {
        List<YtbTbInfo> lstMap = new ArrayList<>();
        int nStartIdx = nPageNum - 1;
        lstMap = lstData.stream().skip(nStartIdx * nPageSize).limit(nPageSize).collect(Collectors.toList());
        return lstMap;
    }

    @RequestMapping(value = "/queryShiTaskZG", method = RequestMethod.POST)
    public AjaxResult queryShiTaskZG(@RequestBody Map<String, Object> parm) {
        try {
            //List<YtbTbInfo> rest = dkShCityService.queryShiTaskZG(parm);
            //return AjaxResult.success(" 成功", rest);
            List<YtbTbInfo> rest = dkShCityService.queryShiTaskZGEX(parm);
            int total = rest.size();
            int nPageNum = Integer.parseInt(parm.get("pageNum") + "");
            int nPageSize = Integer.parseInt(parm.get("pageSize") + "");
            List<YtbTbInfo> lstMap = dataPaginationYtbTbInfo(rest, nPageNum, nPageSize);
            return AjaxResult.success("获取成功", lstMap, total);
        } catch (Exception ex) {
            return AjaxResult.error(" 失败", ex.toString());
        }
    }

    //查询是否有地块提交到省级
    @RequestMapping(value = "/queryRelatedk", method = RequestMethod.POST)
    public AjaxResult queryRelatedk(@RequestBody Map<String, Object> parm) {
        //所有相关地块
        List<Map<String, Object>> rest = xjtbTbBaseService.queryRelatedk(parm);
        //未提交的地块
        List<String> tbbhs = new ArrayList<String>();
        //已经提交的地块
        List<String> tjtbbhs1 = new ArrayList<String>();
        //图斑已经被拆分  地块没有被提交到市级
        String str = "";
        if (rest != null) {
            if (rest.size() > 0) {
                for (int i = 0; i < rest.size(); i++) {
                    String tbbh = rest.get(i).get("tbbh").toString();
                    String dkzt = rest.get(i).get("dkzt").toString();
                    if (!dkzt.equals("3") || !dkzt.equals("8")) {
                        tbbhs.add(tbbh);
                        str += "(" + rest.get(i).get("tbbh") + ")";
                    } else {
                        tjtbbhs1.add(tbbh);
                        str += "(" + rest.get(i).get("tbbh") + ")";
                    }
                }
            }
            if (rest.size() == tbbhs.size() && tjtbbhs1.size() == 0) {
                return AjaxResult.success("获取关联图斑 成功", str);
            } else {
                return AjaxResult.error("获取关联图斑 成功", str);
            }
        }
        return AjaxResult.error("获取关联图斑 失败", -1);
    }

    //市级不通过图斑
    @RequestMapping(value = "/queryShiBtgdk", method = RequestMethod.POST)
    public AjaxResult queryShiBtgdk(@RequestBody Map<String, Object> parm) {
        List<Map<String, Object>> rest = dkShCityService.queryShiBtgdk(parm);
        Integer cnt = dkShCityService.queryShiBtgdkCount(parm);
        if (rest != null) {
            return AjaxResult.success("获取关联图斑 成功", rest, cnt);
        } else {
            return AjaxResult.error("获取关联图斑 成功", rest);
        }
    }

    /*导出*/
    @Log(title = "导出", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/getExport", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public AjaxResult export(@RequestBody Map<String, Object> parm, HttpServletResponse response) {
        ExcelUtils excel = new ExcelUtils();
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        String msg = "";
        String rest = "";
        String category = parm.get("category") + "";
        List<String> Colomnlist = new ArrayList<>();
        try {
            parm.put("username", loginUser.getUsername());

            System.out.println(tempath);
            Colomnlist.clear();
            Colomnlist.add("序号");
            Colomnlist.add("省代码");
            Colomnlist.add("县代码");
            Colomnlist.add("省名称");
            Colomnlist.add("市名称");
            Colomnlist.add("县名称");
            Colomnlist.add("地块编号");
            Colomnlist.add("监测编号");
            Colomnlist.add("核查节点");
            Colomnlist.add("判定类型");
            Colomnlist.add("核查结论");
            Colomnlist.add("核查结果说明");
            Colomnlist.add("违法类型");
            Colomnlist.add("图斑分类");
            Colomnlist.add("具体情形");
            Colomnlist.add("核查说明");
            Colomnlist.add("实际用途");
            Colomnlist.add("判定依据说明");

            List<YtbTbInfo> list = dkShCityService.queryShiTaskEX(parm);
            rest = excel.exportList(response, category, list, Colomnlist, tempath);
            if (rest.contains("error")) {
                msg = "导出失败";
            } else {
                msg = "导出成功";
            }
            return AjaxResult.success(msg, rest);
        } catch (Exception e) {
            e.printStackTrace();
            msg = "导出失败";
        }
        return AjaxResult.error(msg, -1);
    }

    //导出地块列表
    @RequestMapping(value = "/exportDkList", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public AjaxResult exportDkList(@RequestBody Map<String, Object> parm, HttpServletResponse response) {
        String rest = "";
        String msg = "";
        ExcelUtils excel = new ExcelUtils();
        List<String> Colomnlist = new ArrayList<>();
        Colomnlist.clear();
        Colomnlist.add("序号");
        Colomnlist.add("所属省份");
        Colomnlist.add("所属市区");
        Colomnlist.add("所属区县");
        Colomnlist.add("所属乡镇");
        Colomnlist.add("所属村");
        Colomnlist.add("地块编号");
        Colomnlist.add("监测编号");
        Colomnlist.add("核查节点");
        Colomnlist.add("判定类型");
        Colomnlist.add("具体情形");
        Colomnlist.add("实际用途");
        Colomnlist.add("判定依据说明");
        Colomnlist.add("套合地块面积");
        Colomnlist.add("套合地块耕地面积");
        Colomnlist.add("套合地块占用基本农田面积");
        Colomnlist.add("填报地块面积");
        Colomnlist.add("填报地块其中耕地面积");
        Colomnlist.add("填报地块其中基本农田面积");
        Colomnlist.add("填报农用地面积");
        Colomnlist.add("填报地块水田面积");
        Colomnlist.add("填报地块生态保护红线面积");

        Colomnlist.add("市级审核结果");
        Colomnlist.add("市级核查说明");
        Colomnlist.add("市级审核用户");
        Colomnlist.add("市级审核人员");
        Colomnlist.add("省级审核结论");
        Colomnlist.add("省级核查说明");
        Colomnlist.add("省级审核用户");
        Colomnlist.add("省级审核人员");

        Colomnlist.add("农用地转用批准文号");
        Colomnlist.add("农用地转用批文来源");
        Colomnlist.add("农用地转用批准面积");
        Colomnlist.add("农用地转用批准机关");
        Colomnlist.add("农用地转用批准日期");
        Colomnlist.add("增减挂钩批准文号");
        Colomnlist.add("增减挂钩批文来源");
        Colomnlist.add("增减挂钩批准面积");
        Colomnlist.add("增减挂钩批准机关");
        Colomnlist.add("增减挂钩批准日期");
        Colomnlist.add("工矿废弃地批准文号");
        Colomnlist.add("工矿废弃地批文来源");
        Colomnlist.add("工矿废弃地批准面积");
        Colomnlist.add("工矿废弃地批准机关");
        Colomnlist.add("工矿废弃地批准日期");
        Colomnlist.add("不动产权证书批准文号");
        Colomnlist.add("不动产权证书批准来源");
        Colomnlist.add("不动产权证书批准面积");
        Colomnlist.add("不动产权证书批准机关");
        Colomnlist.add("不动产权证书批准日期");
        Colomnlist.add("设施农用地批准文号");
        Colomnlist.add("设施农用地批准来源");
        Colomnlist.add("设施农用地批准面积");
        Colomnlist.add("设施农用地批准机关");
        Colomnlist.add("设施农用地批准日期");
        Colomnlist.add("土地整治验收批准文号");
        Colomnlist.add("土地整治验收批准来源");
        Colomnlist.add("土地整治验收批准面积");
        Colomnlist.add("土地整治验收批准机关");
        Colomnlist.add("土地整治验收批准日期");
        Colomnlist.add("其他批准文号");
        Colomnlist.add("其他批准来源");
        Colomnlist.add("其他批准面积");
        Colomnlist.add("其他批准机关");
        Colomnlist.add("其他批准日期");
        Colomnlist.add("临时用地批准文号");
        Colomnlist.add("临时用地批准来源");
        Colomnlist.add("临时用地批准面积");
        Colomnlist.add("临时用地批准机关");
        Colomnlist.add("临时用地批准日期");
        Colomnlist.add("土地供应批准文号");
        Colomnlist.add("土地供应批准来源");
        Colomnlist.add("土地供应批准面积");
        Colomnlist.add("土地供应批准机关");
        Colomnlist.add("土地供应批准日期");
        Colomnlist.add("先行用地批准文号");
        Colomnlist.add("先行用地批准来源");
        Colomnlist.add("先行用地批准面积");
        Colomnlist.add("先行用地批准机关");
        Colomnlist.add("先行用地批准日期");
        Colomnlist.add("预审批准文号");
        Colomnlist.add("预审批准来源");
        Colomnlist.add("预审批准面积");
        Colomnlist.add("预审批准机关");
        Colomnlist.add("预审批准日期");

        String operName = SecurityUtils.getUsername();
        parm.put("username", operName);
        //获取图斑列表
        List<Integer> lstDkzt = new ArrayList<>();
        String dkzts = parm.get("dkzt") + "";
        if (!dkzts.isEmpty()) {
            for (String zt : dkzts.split(",")) {
                lstDkzt.add(Integer.parseInt(zt.replace("'", "")));
            }
            parm.put("lstDkzt", lstDkzt);
        }
        List<YtbTbInfo> list = dkShCityService.queryShiTaskEX(parm);
        rest = excel.exportDkList(response, "地块列表", list, Colomnlist, tempath);
        if (rest.contains("error")) {
            msg = "导出失败";
        } else {
            msg = "导出成功";
        }
        return AjaxResult.success(msg, rest);
    }

    MultipleFileUnZip multipleFileUnZip = new MultipleFileUnZip();

    //导出矢量数据
    @RequestMapping(value = "/exportDkShpList", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public AjaxResult exportDkShpList(@RequestBody Map<String, Object> parm, HttpServletResponse response) throws ZipException {
        String rest = "";
        String msg = "";
        GdalUtils gdalUtils = new GdalUtils();
        String operName = SecurityUtils.getUsername();
        parm.put("username", operName);
        //获取图斑列表
        List<Integer> lstDkzt = new ArrayList<>();
        String dkzts = parm.get("dkzt") + "";
        if (!dkzts.isEmpty()) {
            for (String zt : dkzts.split(",")) {
                lstDkzt.add(Integer.parseInt(zt.replace("'", "")));
            }
            parm.put("lstDkzt", lstDkzt);
        }
        List<YtbTbInfo> list = dkShCityService.queryShiTaskEX(parm);
        rest = gdalUtils.exportDkList(response, list, tempath);
        if (rest.contains("error")) {
            msg = "导出失败";
        } else {
            List<String> arr = new ArrayList<>();
            arr.add(tempath + "\\" + rest);  //shp
            String zippath = tempath + "\\" + rest.replace("shp", "zip");
            //生成了shp
            String str = tempath + "\\" + rest.replace("shp", "prj");
            File file = new File(str);
            if (file.exists()) {
                arr.add(str);  //prj
            }

            str = tempath + "\\" + rest.replace("shp", "dbf");
            file = new File(str);
            if (file.exists()) {
                arr.add(str);  //prj
            }
            str = tempath + "\\" + rest.replace("shp", "shx");
            file = new File(str);
            if (file.exists()) {
                arr.add(str);  //prj
            }
            rest = multipleFileUnZip.fileZip(zippath, arr);
            if (rest == "") {
                File file1 = new File(zippath);
                rest = file1.getName();
                msg = "导出成功";
            } else {
                msg = "导出失败";
            }
        }
        return AjaxResult.success(msg, rest);
    }
}
